import request from '@/utils/request'

/**
 * 获取系统壁纸列表
 */
export function getWallpapers() {
  return request({
    url: '/wallpapers',
    method: 'get'
  }).then(response => response.data || [])
}

/**
 * 获取用户壁纸列表
 */
export function getUserWallpapers() {
  return request({
    url: '/user/wallpapers',
    method: 'get'
  }).then(response => response.data || [])
}

/**
 * 设置用户当前壁纸
 * @param wallpaper 壁纸URL
 */
export function setUserWallpaper(wallpaper: string) {
  return request({
    url: '/user/settings/wallpaper',
    method: 'post',
    data: { wallpaper }
  })
}

/**
 * 上传壁纸
 * @param file 壁纸文件
 */
export function uploadWallpaper(file: File) {
  const formData = new FormData()
  formData.append('wallpaper', file)
  
  return request({
    url: '/wallpapers/upload',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

/**
 * 删除用户壁纸
 * @param url 壁纸URL
 */
export function deleteWallpaper(url: string) {
  return request({
    url: '/wallpapers/delete',
    method: 'delete',
    data: { url }
  })
} 